package dao;

import entity.Group;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Created by Administrator on 2016/12/2 0002.
 */
public class GroupDao {
    @Autowired
    private SessionFactory sessionFactory;

    public void setSessionFactory(SessionFactory sessionFactory) {

        this.sessionFactory = sessionFactory;
    }
    public SessionFactory getSessionFactory() {

        return sessionFactory;
    }


    private Session getCurrentSession() {
        return sessionFactory.getCurrentSession();
    }

    public Group findGroup(int id){
        Group group = (Group) getCurrentSession().get(Group.class, id);
        return group;
    }
}
